package com.ruoyi.web.controller.mes;


import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.kt.mes.domain.ProcessRouteItemParam;
import com.kt.mes.service.IProcessRouteItemParamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工序参数Controller
 *
 * @author lzc
 * @date 2021-01-29
 */
@RestController
@RequestMapping("/mes/Routeparam")
public class ProcessRouteItemParamController extends BaseController
{
    @Autowired
    private IProcessRouteItemParamService processRouteItemParamService;

    /**
     * 查询工序参数列表
     */
   // @PreAuthorize("@ss.hasPermi('mes:Routeparam:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProcessRouteItemParam processRouteItemParam)
    {
        startPage();
        List<ProcessRouteItemParam> list = processRouteItemParamService.selectProcessRouteItemParamList(processRouteItemParam);
        return getDataTable(list);
    }

    /**
     * 导出工序参数列表
     */
   // @PreAuthorize("@ss.hasPermi('mes:Routeparam:export')")
    @Log(title = "工序参数", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProcessRouteItemParam processRouteItemParam)
    {
        List<ProcessRouteItemParam> list = processRouteItemParamService.selectProcessRouteItemParamList(processRouteItemParam);
        ExcelUtil<ProcessRouteItemParam> util = new ExcelUtil<ProcessRouteItemParam>(ProcessRouteItemParam.class);
        return util.exportExcel(list, "Routeparam");
    }

    /**
     * 获取工序参数详细信息
     */
  //  @PreAuthorize("@ss.hasPermi('mes:Routeparam:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(processRouteItemParamService.selectProcessRouteItemParamById(id));
    }

    /**
     * 新增工序参数
     */
   // @PreAuthorize("@ss.hasPermi('mes:Routeparam:add')")
    @Log(title = "工序参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProcessRouteItemParam processRouteItemParam)
    {
        return toAjax(processRouteItemParamService.insertProcessRouteItemParam(processRouteItemParam));
    }

    /**
     * 修改工序参数
     */
   // @PreAuthorize("@ss.hasPermi('mes:Routeparam:edit')")
    @Log(title = "工序参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProcessRouteItemParam processRouteItemParam)
    {
        return toAjax(processRouteItemParamService.updateProcessRouteItemParam(processRouteItemParam));
    }

    /**
     * 删除工序参数
     */
   // @PreAuthorize("@ss.hasPermi('mes:Routeparam:remove')")
    @Log(title = "工序参数", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(processRouteItemParamService.deleteProcessRouteItemParamByIds(ids));
    }
}

